struct Counter {
    index: usize,
    value: Vec<i32>,
    strs: Vec<String>,
}
impl Counter {
    fn new() -> Counter {
        Counter {
            index: 0,
            value: vec![1, 2, 3, 4, 5],
            strs: vec![String::from("hi")],
        }
    }
}

impl Iterator for Counter {
    type Item = i32;

    fn next(&mut self) -> Option<Self::Item> {
        if self.index < self.value.len() {
            let r = Some(self.value[self.index]);
            self.index += 1;

            return r;
        } else {
            return None;
        }
    }
}

pub trait MyIterator<T> {
    fn next(&mut self) -> Option<T>;
}

impl MyIterator<i32> for Counter {
    fn next(&mut self) -> Option<i32> {
        if self.index < self.value.len() {
            let r = Some(self.value[self.index]);
            self.index += 1;

            return r;
        } else {
            return None;
        }
    }
}
impl MyIterator<String> for Counter {
    fn next(&mut self) -> Option<String> {
        if self.index < self.strs.len() {
            let r = Some(self.strs[self.index].clone());
            self.index += 1;

            return r;
        } else {
            return None;
        }
    }
}
